<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="" />
		<title>CSS3游戏加载效果</title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}

			html,
			body {

				width: 100%;
				height: 100%;
			}

			.wrapper {
				width: 100%;
				height: 100%;
				background: #db4d68;
				/* 弹性盒子 子元素会自动排成一行*/
				display: flex;
				/* 规定子元素水平居中 */
				justify-content: center;
				/* 规定子元素垂直居中 */
				align-items: center;
			}

			.textBOX {
				color: #fff;
				font-size: 30px;
			}

			.monster {
				/* 头发部分 */
				position: relative;
				width: 110px;
				height: 100px;
				/* outline: 1px #000000 solid; */
				border-radius: 20px;
				background-color: #e55a54;
				margin: 10px;
				/* 弹性盒子 子元素会自动排成一行*/
				display: flex;
				/* 设置排列方向 */
				flex-direction: column;
				/* 规定子元素垂直居中(视觉水平居中) */
				align-items: center;
				/* 规定子元素水平居中(视觉垂直居中) */
				justify-content: center;
				/* 跳起来的动画: 名称 过度时间 无限重复 往返有动画 */
				animation: tiao 0.8s infinite alternate;
				/* 阴影 水平偏移量 竖直偏移量 模糊半径 颜色 */
				box-shadow: 0px 10px 20px rgb(0,0,0,0.2)
				
				
			}
			.monster .eye{
				width: 40%;
				height: 40%;
				border-radius: 50%;
				background: #fff;
				/* 弹性盒子 子元素会自动排成一行*/
				display: flex;
				/* 规定子元素水平居中 */
				justify-content: center;
				/* 规定子元素垂直居中 */
				align-items: center;
			}
			.monster .eye .eyeball{
				width: 50%;
				height: 50%;
				border-radius: 50%;
				background: #0c4475;
				/* 眼睛动画 */
				animation: move 1.6s infinite alternate;
			}
			.monster .mouth{
				width:32%;
				height:8px;
				border-radius: 12px;
				background-color: #fff;
				margin-top: 15%;
			}
			/* CSS3伪类选择器 :nth-of-type(1) */
			/* :not(选中没有这个类名的元素) */
			
			.monster::before,
			.monster::after{
			  content:'';
			  display: block;
			  width: 20%;
			  height: 10px;
			  background: #fff;
			  border-radius: 5px;
			  /* 头发部分 */
			  position: absolute;
			  left:50%;
			  top:-10px;
			}
			.monster::before{
				transform: translateX(-70%) rotateZ(45deg);
			}
			.monster::after{
				transform: translateX(-30%) rotateZ(-45deg);
			}
			@keyframes tiao{
				0%{
					top:0;
					box-shadow: 0px 10px 20px rgb(0,0,0,0.2);
				}
				50%{
					top:0;
					box-shadow: 0px 10px 20px rgb(0,0,0,0.2);
				}
				100%{
					top:-50px;
					box-shadow: 0px 120px 20px rgb(0,0,0,0.2);
				}
			}
			.monster.blue {
				background: #0C4475;
				/* 延时执行动画 */
				animation-delay: 0.5s;
			}
			.monster.blue .eyeball{
				background: #E55A54;
			}
			@keyframes move{
				0%{
					/* left也行 */
					transform: translateX(50%);
				}
				100%{
					transform: translateX(-50%);
				}
			}
			/* 遮罩加载层 */
			.pageLoading{
				width: 100%;
				height: 100%;
				position: fixed;
				left:0;
				top:0;
				background: #0C4475;
				
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
			}
			.loading{
				width: 200px;
				height: 8px;
				background: #fff;
				border-radius:4px;
				margin-top: 80px;
			}
			.loading .bar{
				width: 0%;
				height: 100%;
				border-radius: 4px;
				background: #E55A54;
			}
			.pageLoading.complete{
				opacity: 0;
				/* 动画时间 延迟时间 */
				transition: 0.5s linear 0.5s;
			}
			.pageLoading.complete .monster{
				transform:scale(0.1) rotateZ(999deg);
				transition: 0.6s ;
			}
		</style>
	</head>
	<body>
		<div class="wrapper">
			<div class="textBOX">
				<h2>Hello
					<br>There
				</h2>
				<h3>Ahhh we will eat you!!!</h3>
			</div>
			<div class="monster">
				<div class="eye">
					<div class="eyeball"></div>
				</div>
				<div class="mouth"></div>
			</div>

			<div class="monster blue">
				<div class="eye">
					<div class="eyeball"></div>
				</div>
				<div class="mouth"></div>
			</div>
		</div>
		<div class="pageLoading">
			<div class="monster">
				<div class="eye">
					<div class="eyeball"></div>
				</div>
				<div class="mouth"></div>
			</div>
			<div class="loading">
				<div class="bar"></div>
			</div>
		</div>
		<script type="text/javascript">
			var per=0;
			var page=document.getElementsByClassName("pageLoading")[0];
			var bar=document.getElementsByClassName('bar')[0];
			var timer=setInterval(function(){
				bar.style.width=per+'%';
				per+=1;
				if(per>100){
					clearInterval(timer);
					page.classList.add('complete');
				}
			},30);
			
		</script>
	</body>
</html>
